home *** CD-ROM | disk | FTP | other *** search
- Path: in2.uu.net!interaccess!usenet
- From: brianmcg@interaccess.com (Brian V. McGroarty)
- Newsgroups: comp.lang.c
- Subject: Re: pointer-to-pointer usage
- Date: 20 Mar 1996 14:18:46 GMT
- Organization: Internet Squire
- Message-ID: <4ip446$g6h@nntp.interaccess.com>
- References: <4inbmp$506@ra.nrl.navy.mil>
- Reply-To: brianmcg@interaccess.com
- NNTP-Posting-Host: d41-isdn.nhe.interaccess.com
- X-Newsreader: Internet Squire 1.20
-
- The function "int change_ptr( tempType **temp )" expects to see a pointer
- to a pointer to a tempType. In the lines which are generating errors, you
- are only passing a pointer to tempType.
-
-
- Here is what each does:
-
- >change_ptr(temp1);
-
- This is simply a copy of temp1, which is a pointer to tempType. You would
- need to take its address, for example:
-
- change_ptr( &temp1 );
-
-
- >change_ptr(&(*temp1));
- >change_ptr(&*temp1);
-
- In both of the above, you are using * to resolve temp1 to the actual
- tempType before taking the address.
-
-
-
- John Peng-yung Cheng wrote:
- >Greetings,
-
- > Could someone explain the following warnings that I get when
- >I compile with GNU compiler? Please ignore the -D switches in the
- >compiler statement; I am developing for vxWorks, but the OS should not
- >make a difference. Obviously, the functions do not do anything useful,
- >but are just an extraction of my actual code.
-
- [...]
-
- >In particular, the first four function calls to change_ptr() are
- >equivalent, but only the last one does not generate a warning. Also,
- >the declaration and usage of change_ptr_2 does not generate any warnings.
-
- [...]
-
- >int change_ptr(tempType **temp)
- [...]
-
- >tempType *temp1;
- >tempPtr temp2;
- >
- >change_ptr(temp1);
- >change_ptr(&(*temp1));
- >change_ptr(&*temp1);
- >change_ptr((tempType **)temp1);
- >change_ptr_2(&temp2);
-
-
-
- ---
- Brian Valters McGroarty -- brianmcg@bix.com
- phone/fax (847) 439-7714
-
-
-
-
-
-